<template>
 <div>
   <div class="head">
    <el-row>
      <el-col :span="12" >
      <!-- <el-input v-model="input" placeholder="请输入内容"></el-input> -->
      </el-col>
        <el-col :span="10" :offset="0">
        <!-- <el-button type="primary" icon="el-icon-search" @click="scarch">搜索</el-button> -->
          <el-button type="primary" icon=" el-icon-plus" @click="add">添加</el-button>  
      </el-col>
    </el-row>
   </div>
   <el-table :data="pageInfo.list" class="tb-edit" style="width: 100%">
     <el-table-column prop="tid"  label="序号"  width="120"></el-table-column>
     <el-table-column prop="tname"  label="姓名"  width="120"></el-table-column>
     <el-table-column  label="职位"  width="120">
        <template slot-scope="scope">
　　　　 　<span v-if="scope.row.state== '0'">启用</span>
　　　　 　<span v-if="scope.row.state== '1'">禁用</span>
　　　　</template>
     </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini"  @click="edit(scope.row)">编辑</el-button>
        <!-- <el-button size="mini" type="danger" >删除</el-button> -->
         <el-button size="mini" type="success" v-if="scope.row.state === '1'"  @click="handleDelete(0)">启用</el-button>
         <el-button size="mini" type="danger" v-if="scope.row.state === '0'"  @click="handleDelete(1)">禁用</el-button>
      </template>
    </el-table-column>
  </el-table>
 
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-count="pageInfo.pages"
      :current-page="pageNum"
      :page-sizes="limits"
      :page-size="pageSize"
      layout="total,sizes, prev, pager, next"
      >
      <!--  -->
    </el-pagination>
    <!-- 表单 -->
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item label="序号" hidden :label-width="formLabelWidth">
            <el-input hidden v-model="form.fid" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="类型名" :label-width="formLabelWidth">
            <el-input v-model="form.tname" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="submit()">确 定</el-button>
        </div>
    </el-dialog>
 </div>
</template>

<script>
  export default {
    
    data() {
      return {
      
        roles:[],
        pageInfo: {
          list:[],
        },form: {},
        dialogFormVisible:false,
        input:'',
        formLabelWidth: '120px',
        limits:[3,5,7],
        pageSize:7,// limits 的第几条
        pageNum:1,// 第几页
        action:''
       
      }
    },
    created(){
      this.$http.get("/backuser/allRname").then(res=>{
        this.roles=res;
      })
      this.scarch();
    },
    methods: {
      
      submit(){
        this.dialogFormVisible=false;
        // let authuser=this.$qs.parse(sessionStorage.getItem("authUser"))

        this.$http.get(this.action,{params:{...this.form}}).then(res=>{
          if(res){
               this.$message({message: '提交成功', type: 'success'});
               this.scarch();
           }else{
             this.$message.error("提交失败")
             this.scarch();
           }
        })
      },
      add(){
        this.dialogFormVisible=true;
        this.form={};
        this.action="/video_type/add"
      },

      edit(row) {
        this.dialogFormVisible=true;
        this.form=row;
        this.action="/video_type/update"
      },
       jinyong(uid) {
      this.$http.get('/foul/state',{params:{fid:uid,state:0}}).then(res=>{
          if(res){
            this.$message("修改成功")
            this.scarch();
          }
        })
        
      },
       qiyong(uid) {
        this.$http.get('/foul/state',{params:{fid:uid,state:1}}).then(res=>{
          if(res){
            this.$message("修改成功")
            this.scarch();
          }
        })
        
      },scarch(){
         this.$http.get('/video_type/finAll', {params: {pageNum: this.pageNum,pageSize:this.pageSize}}).then(res=>{
          this.pageInfo=res
        })
      },handleSizeChange(a){
       
        this.pageSize=a

        this.scarch();
      },handleCurrentChange(a){       
          this.pageNum=a
        this.scarch();
      }
      
    }
  }
</script>
<style scoped>
 .head{
   padding: 10px 5px;
 }
 

</style>
<style lang="scss" scoped>
.tb-edit.el-input {
  display: none;
}
.tb-edit.current-row.el-input {
  display: block;
}
.tb-edit.current-row.el-input + span {
  display: none;
}
</style>
